package com.jxdinfo.hussar.example.mes.pro.service.impl;

import java.util.List;

import com.jxdinfo.hussar.example.common.constant.UserConstants;
import com.jxdinfo.hussar.example.common.utils.StringUtils;
import com.jxdinfo.hussar.example.mes.wm.domain.WmProductRecpt;
import com.jxdinfo.hussar.example.mes.wm.domain.tx.ProductRecptTxBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jxdinfo.hussar.example.common.utils.DateUtils;
import com.jxdinfo.hussar.example.mes.pro.dao.ProProductRecptMapper;
import com.jxdinfo.hussar.example.mes.pro.domain.ProProductRecpt;
import com.jxdinfo.hussar.example.mes.pro.service.IProProductRecptService;

/**
 * 包装入库Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-08
 */
@Service
public class ProProductRecptServiceImpl implements IProProductRecptService
{
    @Autowired
    private ProProductRecptMapper proProductRecptMapper;

    /**
     * 查询包装入库
     *
     * @param recptId 包装入库主键
     * @return 包装入库
     */
    @Override
    public ProProductRecpt selectProProductRecptByRecptId(Long recptId)
    {
        return proProductRecptMapper.selectProProductRecptByRecptId(recptId);
    }

    /**
     * 查询包装入库列表
     *
     * @param proProductRecpt 包装入库
     * @return 包装入库
     */
    @Override
    public List<ProProductRecpt> selectProProductRecptList(ProProductRecpt proProductRecpt)
    {
        return proProductRecptMapper.selectProProductRecptList(proProductRecpt);
    }

    @Override
    public String checkUnique(ProProductRecpt proProductRecpt) {
        ProProductRecpt recpt = proProductRecptMapper.checkUnique(proProductRecpt);
        Long recptId = proProductRecpt.getRecptId() ==null? -1L:proProductRecpt.getRecptId();
        if(StringUtils.isNotNull(recpt) && recpt.getRecptId().longValue() != recptId.longValue()){
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    /**
     * 新增包装入库
     *
     * @param proProductRecpt 包装入库
     * @return 结果
     */
    @Override
    public int insertProProductRecpt(ProProductRecpt proProductRecpt)
    {
        proProductRecpt.setCreateTime(DateUtils.getNowDate());
        return proProductRecptMapper.insertProProductRecpt(proProductRecpt);
    }

    /**
     * 修改包装入库
     *
     * @param proProductRecpt 包装入库
     * @return 结果
     */
    @Override
    public int updateProProductRecpt(ProProductRecpt proProductRecpt)
    {
        proProductRecpt.setUpdateTime(DateUtils.getNowDate());
        return proProductRecptMapper.updateProProductRecpt(proProductRecpt);
    }

    /**
     * 批量删除包装入库
     *
     * @param recptIds 需要删除的包装入库主键
     * @return 结果
     */
    @Override
    public int deleteProProductRecptByRecptIds(Long[] recptIds)
    {
        return proProductRecptMapper.deleteProProductRecptByRecptIds(recptIds);
    }

    /**
     * 删除包装入库信息
     *
     * @param recptId 包装入库主键
     * @return 结果
     */
    @Override
    public int deleteProProductRecptByRecptId(Long recptId)
    {
        return proProductRecptMapper.deleteProProductRecptByRecptId(recptId);
    }

    @Override
    public List<ProductRecptTxBean> getTxBean(Long recptId) {
        return proProductRecptMapper.getTxBean(recptId);
    }
}
